<!DOCTYPE html>
<html>
<head>
    {include file="Public:header"}
</head>
<body class="white-bg" style="padding: 3px">
<div class="page-heade">
    <h2 class="title_color text-center">用户管理</h2>
</div>
<div class="padding-10">
    <span class="lr_5"></span>
    <a href="{:url('isdel')}" class="btn btn-info" style="float: right;">回收站</a>
    <a href="{:url('add')}" class="btn btn-w-m btn-info" id="sync">新增</a>
</div>
<div class="padding-10">

    <table class="table table-striped table-bordered table-hover bud_hei text-center" id="editable">
        <thead>
            <tr class="info">
                <th class="text-center">No.</th>
                <th class="text-center">用户名</th>
                <th class="text-center">角色</th>
                <th class="text-center">对应职员</th>
                <th class="text-center">用户类型</th>
                <th class="text-center">状态</th>
                <th class="text-center">是否允许移动端登录</th>
                <th class="text-center">微信号</th>
                <th class="text-center">操作</th>
            </tr>
        </thead>
        <tbody>
        {volist name="data" id="row" key="k"}
            <tr class="gradeX">
                <td>{$k+(request()->param('page')?request()->param('page'):1-1)*10}</td>
                <td>{$row.login_name}</td>
                <td>{$row.role}</td>
                <td>{$row.em_name}</td>
                <td>{$row.yhlx}</td>
                <td>{$row.state}</td>
                <td>{$row.power}</td>
                <td>{$row.wechat}</td>
                <td>
                    <a href="{:url('update',['id'=>$row.id])}">修改</a>
                    <a href="{:url('csmm',['id'=>$row.id])}" class="csmm">重设密码</a>
                    <a href="{:url('delete',['id'=>$row.id])}" class="sc">删除</a>
                    <a href="{:url('wxhsz',['id'=>$row.employee_id])}" class="wxhsz">微信号设置</a>
                    <a href="{:url('jbwx',['id'=>$row.employee_id])}" class="jbwx">解绑微信</a>
                </td>
            </tr>
        {/volist}
        </tbody>

    </table>
       <div class="row text-center" id="pageText" style="padding: 0;margin: 0;">
					<div class="col-sm-6 text-left"><div class="padding-10 countSize">共{$count}条记录，{$maxpage}页&nbsp;&nbsp;</div></div>
					<div class="col-sm-6 text-right">{$page}</div>
		</div>
</div>

</body>
</html>
{include file="Public:footer"}
<script>
    $(function () {

        //删除
        $('.sc').on('click',function () {
            var link = $(this).prop('href')
            swal({
                    title: "您确定要删除该条嘛?",
                    text: "删除后在回收站查找！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    closeOnConfirm: false
                },
                function(is) {
                    if(is){
                        $.post(link,function (data) {
                            if(data.success){
                                swal({title:data.msg},function () {
                                    location.reload()
                                })
                            }else{
                                swal('',data.msg,'error')
                            }
                        },'json')
                    }
                })
            return false
        })
        //重设密码
        $('.csmm').on('click',function () {
            var link = $(this).prop('href')
            layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:link,
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()
                    $.post(link,a.find('form').serialize(),function (data) {
                        if(data.success){
                            swal({title:data.msg},function () {
                                layer.close(i)
                            })
                        }else{
                            swal('',data.msg,'error')
                        }
                    },'json')
                    return false
                }
            })
            return false
        })
        //解绑微信
        $('.jbwx').on('click',function () {
            var link = $(this).prop('href')
            swal({
                    title: "您确定要解绑微信嘛?",
                    text: "解绑后无法使用微信端，需要重新认证后才能登陆！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    closeOnConfirm: false
                },
                function(is) {
                    if(is){
                        $.post(link,function (data) {
                            if(data.success){
                                swal({title:data.msg},function () {
                                    location.reload()
                                })
                            }else{
                                swal('',data.msg,'error')
                            }
                        },'json')
                    }
                })
            return false
        })
        //微信号设置
        $('.wxhsz').on('click',function () {
            var link = $(this).prop('href')
            layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:link,
                btn:['确定','关闭'],
                yes:function (i,o) {
                    var a = $(o).find('iframe').contents()
                    $.post(link,a.find('form').serialize(),function (data) {
                        if(data.success){
                            swal({title:data.msg},function () {
                                layer.close(i)
                            })
                        }else{
                            swal('',data.msg,'error')
                        }
                    },'json')
                    return false
                }
            })
            return false
        })
        //新增
        $('#new').on('click', function () {
            $('body').append('<div class="channel_popbox" id="channel_popbox">' +
                '<div class="channel_pop_content ibox" style="height:350px;margin-top:-175px;"><div class="ibox-header"><button style="position: absolute;right: 7px;top: 3px;" type="button" class="close" data-dismiss="modal"><span aria-hidden="true" style="font-size:28px;">×</span><span class="sr-only">关闭</span>\n' +
                '</button><h2 style="text-align:center;" class="title_color">新增</h2></div>' +
                '<div class="ibox-content">' +
                '<form role="form" id="formadd" method="post" action="{:url("add")}">\n' +
                '<div class="form-group">\n' +
                '<label>行政省份名称：</label>\n' +
                '<input name="title" type="text" placeholder="行政省份名称" class="form-control">\n' +
                '</div>\n' +
                '<div class="form-group">\n' +
                '<label>描述：</label>\n' +
                '<textarea name="brief" class="form-control" id="" cols="30" rows="5"></textarea>\n' +
                '</div>\n' +
                '<div class="text-center" style="padding:20px 0">\n' +
                '<input class="btn btn-sm btn-primary" type="submit" id="tijiao" value="提 交">\n' +
                '</div>\n' +
                '</form>' +
                '</div>' +
                '</div>' +
                '</div>')
        })
        $('body').on('click', '#channel_popbox .close', function () {
            $('#channel_popbox').remove()
        })
        $('body').on('click', '#channel_popbox .channel_pop_content', function () {
            return false
        })
        $('body').on('click', '#channel_popbox #tijiao', function () {
            var form = $('#channel_popbox #formadd')
            var data = form.serialize()
            $.ajax({
                'type': 'post',
                'url': form.attr('action'),
                'data': data,
                'dataType': 'json',
                'success': function (data) {
                    if (data.success) {
                        swal({
                            title: data.msg,
                            type: "success"
                        }, function () {
                            location.reload()
                        });

                    } else
                        swal({
                            title: data.msg,
                            type: "warning"
                        });
                }
            })
            return false
        })
        //修改
        $('.xiugai').on('click', function () {
            var id = $(this).data('id')
            var title = $(this).data('title')
            var brief = $(this).data('brief')
            $('body').append('<div class="channel_popbox" id="channel_popbox">' +
                '<div class="channel_pop_content ibox" style="height:350px;margin-top:-175px;">' +
                '<div class="ibox-header"><button style="position: absolute;right: 7px;top: 3px;" type="button" class="close" data-dismiss="modal"><span aria-hidden="true" style="font-size:28px;">×</span><span class="sr-only">关闭</span>\n' +
                '</button><h2 style="text-align:center;" class="title_color">修改</h2></div>' +
                '<div class="ibox-content">' +
                '<form role="form" id="formadd" method="post" action="{:url("update")}">\n' +
                '<input type="hidden" name="id" value="' + id + '">' +
                '<div class="form-group">\n' +
                '<label>行政省份名称：</label>\n' +
                '<input name="title" type="text" placeholder="行政省份名称" class="form-control" value="' + title + '">\n' +
                '</div>\n' +
                '<div class="form-group">\n' +
                '<label>描述：</label>\n' +
                '<textarea name="brief" class="form-control" id="" cols="30" rows="5">' + brief + '</textarea>\n' +
                '</div>\n' +
                '<div class="text-center" style="padding:20px 0">\n' +
                '<input class="btn btn-sm btn-primary" type="submit" id="tijiao" value="提 交">\n' +
                '</div>\n' +
                '</form>' +
                '</div>' +
                '</div>' +
                '</div>')
        })
        //删除
        $('.shanchu').click(function () {
            var id = $(this).data('id')
            swal({
                title: "您确定要删除这条信息吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "删除",
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    'type': 'post',
                    'url': '{:url("delete")}',
                    'data': {'id': id},
                    'dataType': 'json',
                    'success': function (data) {
                        if (data.success) {
                            location.reload()
                        } else
                            swal(data.msg, "", "error");
                    }
                })

            });
        });

    })
</script>